package com.maxmlr.mybatisplus.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 
 * @Package com.maxmlr.common.config
 * @ClassName Swagger2
 * @Description TODO
 * @author max
 * @since 2018年12月15日 下午6:12:16
 * @version 1.0
 * @Copyright Copyright (c) 2018: www.maxmlr.com.
 */
@Configuration // 必须存在
@EnableSwagger2 // 必须存在
@EnableWebMvc // 必须存在
@ComponentScan(basePackages = { "com.maxmlr.mybatisplus.*.controller" })
public class Swagger2 {

	@Bean
	public Docket customDocket() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.basePackage("com.maxmlr.*.controller")).paths(PathSelectors.any()).build();
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("boot-demo APIs")// API 标题
				.description("包括增删改查 APIs")// API描述
				.termsOfServiceUrl("http://www.baidu.com").contact("测试").version("1.1.0").build();
	}

}
